package me.mcx.mcx.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import me.mcx.common.annotation.Log;
import me.mcx.common.core.controller.BaseController;
import me.mcx.common.core.domain.AjaxResult;
import me.mcx.common.core.page.TableDataInfo;
import me.mcx.common.enums.BusinessType;
import me.mcx.common.utils.poi.ExcelUtil;
import me.mcx.mcx.domain.McxTeam;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import me.mcx.mcx.service.IMcxTeamService;

/**
 * 团队风采Controller
 * 
 * @author mcx
 * @date 2024-09-21
 */
@RestController
@RequestMapping("/mcx/team")
public class McxTeamController extends BaseController
{
    @Autowired
    private IMcxTeamService mcxTeamService;

    /**
     * 查询团队风采列表
     */
    @PreAuthorize("@ss.hasPermi('mcx:team:list')")
    @GetMapping("/list")
    public TableDataInfo list(McxTeam mcxTeam)
    {
        startPage();
        List<McxTeam> list = mcxTeamService.selectMcxTeamList(mcxTeam);
        return getDataTable(list);
    }

    /**
     * 导出团队风采列表
     */
    @PreAuthorize("@ss.hasPermi('mcx:team:export')")
    @Log(title = "团队风采", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, McxTeam mcxTeam)
    {
        List<McxTeam> list = mcxTeamService.selectMcxTeamList(mcxTeam);
        ExcelUtil<McxTeam> util = new ExcelUtil<McxTeam>(McxTeam.class);
        util.exportExcel(response, list, "团队风采数据");
    }

    /**
     * 获取团队风采详细信息
     */
    @PreAuthorize("@ss.hasPermi('mcx:team:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(mcxTeamService.selectMcxTeamById(id));
    }

    /**
     * 新增团队风采
     */
    @PreAuthorize("@ss.hasPermi('mcx:team:add')")
    @Log(title = "团队风采", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody McxTeam mcxTeam)
    {
        return toAjax(mcxTeamService.insertMcxTeam(mcxTeam));
    }

    /**
     * 修改团队风采
     */
    @PreAuthorize("@ss.hasPermi('mcx:team:edit')")
    @Log(title = "团队风采", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody McxTeam mcxTeam)
    {
        return toAjax(mcxTeamService.updateMcxTeam(mcxTeam));
    }

    /**
     * 删除团队风采
     */
    @PreAuthorize("@ss.hasPermi('mcx:team:remove')")
    @Log(title = "团队风采", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mcxTeamService.deleteMcxTeamByIds(ids));
    }
}
